package dormouse.fx;

import java.net.URL;
import java.util.Locale;
import java.util.ResourceBundle;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import dormouse.DormouseContext;


/**
 * This class is the main entry-point for Dormouse. This application makes use
 * of the SpringFramework and uses an XML file to configure the beans that are
 * used within it.
 */
public class Dormouse extends Application {
	
	private ApplicationContext context = null;

	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		
		context = new ClassPathXmlApplicationContext(new String[]{"/conf/DormouseFX.xml"});
		DormouseContext.setContext(context);
		
		URL url = getClass().getResource("/fxml/Dormouse.fxml");
		
		
		FXMLLoader loader = new FXMLLoader(url);
		loader.setResources(ResourceBundle.getBundle("i18n.Dormouse",Locale.getDefault()));
		DormouseController controller = loader.getController();
		AnchorPane root = (AnchorPane)loader.load();
		
		Scene scene = new Scene(root);
		stage.setTitle("Dormouse");
		stage.setScene(scene);
		
		stage.show();
		
	}
	
	

}
